<template>
  <div class="search">
    <div class="bill">
    <div>顾客联</div>
    <div class="place">请留意您的取餐账单号</div>
    <div class="self">自取顾客联</div>
    <div>XXX店铺（XXXX分店）</div>
    <div>010-123456789</div>
    <div class="self">--结账单--</div>
    <div class="place">账单号：X000001</div>
    <div>账单类型：堂食</div>
    <div>人数：2</div>
    <div>收银员：张三</div>
    <div>开单时间：2021-01-01 18:00:30</div>
    <div>结账时间：2021-01-01 18:01:24</div>

    <hr/>

    <table>
      <tr>
        <td width="50" align="center">数量</td>
        <td width="190">品项</td>
        <td width="50" align="center">金额</td>
      </tr>
      <tr>
        <td valign="top">1</td>
        <td>玉米肉松蛋饼2片<br>
          2 X --玉米肉松蛋饼<br>
          2 X --现磨豆浆（热/甜）
        </td>
        <td valign="top" align="right">8.00</td>
      </tr>
    </table>

    <hr/>

    <table>
      <tr>
        <td width="246">合计</td>
        <td width="50" align="right">8.00</td>
      </tr>
      <tr>
        <td>微支付</td>
        <td align="right">8.00</td>
      </tr>
    </table>

    <hr/>

    <div>打印时间：2021-01-01 18:01:40</div>

    <hr />

    </div>




    <Card>
      <Form
        ref="searchForm"
        :model="searchForm"
        inline
        :label-width="70"
        class="search-form"
      >
        <Form-item label="订单编号" prop="orderSn">
          <Input
            type="text"
            v-model="searchForm.orderSn"
            clearable
            placeholder="请输入订单编号"
            style="width: 160px"
          />
        </Form-item>
        <Form-item label="会员名称" prop="buyerName">
          <Input
            type="text"
            v-model="searchForm.buyerName"
            clearable
            placeholder="请输入会员名称"
            style="width: 160px"
          />
        </Form-item>
        <Form-item label="订单状态" prop="orderStatus">
          <Select
            v-model="searchForm.orderStatus"
            placeholder="请选择"
            clearable
            style="width: 160px"
          >
            <Option value="UNPAID">未付款</Option>
            <Option value="PAID">已付款</Option>
            <Option value="UNDELIVERED">待发货</Option>
            <Option value="DELIVERED">已发货</Option>
            <Option value="COMPLETED">已完成</Option>
            <Option value="CANCELLED">已取消</Option>
            <Option value="STAY_PICKED_UP">待自提</Option>
          </Select>
        </Form-item>
        <Form-item label="订单类型" prop="orderType">
          <Select
            v-model="searchForm.orderPromotionType"
            placeholder="请选择"
            clearable
            style="width: 160px"
          >
            <Option value="NORMAL">普通订单</Option>
            <Option value="PINTUAN">拼团订单</Option>
            <Option value="GIFT">赠品订单</Option>
            <Option value="POINTS">积分订单</Option>
            <Option value="KANJIA">砍价订单</Option>
          </Select>
        </Form-item>
        <Form-item label="下单时间">
          <DatePicker
            v-model="selectDate"
            type="datetimerange"
            format="yyyy-MM-dd"
            clearable
            @on-change="selectDateRange"
            placeholder="选择起始时间"
            style="width: 160px"
          ></DatePicker>
        </Form-item>
<!--        <Form-item label="配送方式" prop="orderStatus">-->
<!--          <Select-->
<!--            v-model="searchForm.orderStatus"-->
<!--            placeholder="请选择"-->
<!--            clearable-->
<!--            style="width: 160px"-->
<!--          >-->
<!--            <Option value="SELF">自提</Option>-->
<!--            <Option value="RIDER">骑手</Option>-->
<!--            <Option value="LOGISTICS">物流</Option>-->
<!--          </Select>-->
<!--        </Form-item>-->
<!--        <Form-item label="配送状态" prop="orderStatus">-->
<!--          <Select-->
<!--            v-model="searchForm.orderStatus"-->
<!--            placeholder="请选择"-->
<!--            clearable-->
<!--            style="width: 160px"-->
<!--          >-->
<!--            <Option value="UNPAID">未付款</Option>-->
<!--            <Option value="PAID">已付款</Option>-->
<!--            <Option value="UNDELIVERED">待发货</Option>-->
<!--            <Option value="DELIVERED">已发货</Option>-->
<!--            <Option value="COMPLETED">已完成</Option>-->
<!--            <Option value="CANCELLED">已取消</Option>-->
<!--            <Option value="STAY_PICKED_UP">待自提</Option>-->
<!--          </Select>-->
<!--        </Form-item>-->

        <Button @click="handleSearch" type="primary" class="search-btn"
          >搜索</Button
        >
        <Button @click="handleReset" class="search-btn">重置</Button>
      </Form>
      <Modal :class-name="pointer"
        :title="modalTitle"
        v-model="modalVisible"
        :mask-closable="false"
        :width="700"
      >
        <Form ref="form" :label-width="100" :rules="formValidate">
          <FormItem label="待发货" prop="goods" style="width:90%;">
            <span style="font-size: larger;">{{deliver.num}}单</span><Button @click="checkOrder" size="small" style="margin-left: 10px;margin-bottom: 2px">查看</Button>
          </FormItem>
          <FormItem label="物流" prop="logisticses" style="width:90%;">
            <div style="display: flex;flex-wrap: wrap;" >
              <div v-for="item in deliver.logisticsList"  @click="logisticsItemFun(item)">
                  <span v-if="item.selected==='1'" style="color:white;background-color:green;padding:5px 10px;margin:5px;border-radius: 5px;cursor: pointer">{{item.name}}</span>
                  <span v-else style="background-color:rgba(201,197,197,0);padding:5px 10px;margin:5px;border-radius: 5px;cursor: pointer">{{item.name}}</span>
              </div>
            </div>
            <span style="color: red;margin-top: 10px;">默认从可用物流列表随机选择一个物流发货</span>
          </FormItem>
          <FormItem label="打印机" prop="printer" style="width:90%;">
            <Select @on-change="" v-model="deliver.printer" >
              <Option v-for="item in deliver.printerList" :key="item.index" :value="item.name" >{{ item.name }}
              </Option>
            </Select>
            <span style="color: red;margin-top: 10px;">请选择电子面单打印机</span>
          </FormItem>
        </Form>
        <div slot="footer">
          <span style="float: left;color: red;font-size: 18px">{{tip}}</span>
          <Button type="text" @click="modalVisible = false">取消</Button>
          <Button type="primary" :loading="orderDeliverLoading" @click="orderDeliverSubmit">批量发货</Button>
        </div>
      </Modal>
      <Modal
        title="批量打印小票"
        v-model="receiveModalVisible"
        :mask-closable="false"
        :width="700"
      >
        <Form ref="form" :label-width="100">
          <FormItem label="待自提" prop="goods" style="width:90%;">
            <span style="font-size: larger;">{{receive.num}}单</span><Button @click="checkSelfOrder" size="small" style="margin-left: 10px;margin-bottom: 2px">查看</Button>
          </FormItem>
          <FormItem label="打印机" prop="printer" style="width:90%;">
            <Select @on-change="" v-model="receive.printer" >
              <Option v-for="item in receive.printerList" :key="item.index" :value="item.name" >{{ item.name }}
              </Option>
            </Select>
          </FormItem>
        </Form>
        <div slot="footer">
          <Button type="text" @click="receiveModalVisible = false">取消</Button>
          <Button type="primary" :loading="orderDeliverLoading" @click="printBillsSubmit">批量打印小票</Button>
        </div>
      </Modal>
      <!-- 订单核销 -->
      <Modal v-model="batchTakeModal" width="530">
        <p slot="header">
          <Icon type="edit"></Icon>
          <span>订单批量核销</span>
        </p>
        <div>
          <Form label-position="left" :label-width="100">
            <FormItem label="核销码">
              <Label v-for="item in batchTakeOrders" :key="item.verificationCode" :value="item.verificationCode" >{{item.verificationCode}}</Label>
            </FormItem>
          </Form>
        </div>
        <div slot="footer" style="text-align: right">
          <Button @click="batchTakeModal = false">关闭</Button>
          <Button type="primary" @click="batchTake">批量核销</Button>
        </div>
      </Modal>

      <!-- 订单核销 -->
      <Modal v-model="orderTakeModal" width="530">
        <p slot="header">
          <Icon type="edit"></Icon>
          <span>订单核销</span>
        </p>
        <div>
          <Form label-position="left" :label-width="100">
            <FormItem label="核销码" prop="qrCode">
              <Input v-model="orderTakeForm.verificationCode" size="large" maxlength="10"></Input>
            </FormItem>
          </Form>
        </div>
        <div slot="footer" style="text-align: right">
          <Button @click="orderTakeModal = false">关闭</Button>
          <Button type="primary" @click="orderTakeSubmit">核销</Button>
        </div>
      </Modal>

      <div class="export">
        <Button type="primary" class="mr_10" @click="showOrderDeliverModal">
          批量物流发货
        </Button>
        <Button type="primary" class="mr_10" @click="showOrderDeliverModal2">
          批量打印自提小票
        </Button>
        <Button type="primary" class="mr_10" @click="showOrderDeliverModal2">
          批量核销自提单
        </Button>
<!--        <Button type="primary" class="mr_10" @click="expressOrderDeliver">-->
<!--          EXCEL批量发货-->
<!--        </Button>-->
<!--        <download-excel-->
<!--          style="display: inline-block"-->
<!--          :data="data"-->
<!--          :fields="excelColumns"-->
<!--          :fetch="exportOrder"-->
<!--          name="待发货订单.xls"-->
<!--        >-->
<!--          <Button>导出待发货订单</Button>-->
<!--        </download-excel>-->
      </div>
      <Table
        :loading="loading"
        border
        :columns="columns"
        :data="data"
        ref="table"
      ></Table>
      <Row type="flex" justify="end" class="mt_10">
        <Page
          :current="searchForm.pageNumber"
          :total="total"
          :page-size="searchForm.pageSize"
          @on-change="changePage"
          @on-page-size-change="changePageSize"
          :page-size-opts="[10, 20, 50]"
          size="small"
          show-total
          show-elevator
          show-sizer
        ></Page>
      </Row>
    </Card>
  </div>
</template>

<script>
import * as API_Order from "@/api/order";
import JsonExcel from "vue-json-excel";
import Cookies from "js-cookie";
import {validateMobile} from "@/libs/validate";
import { getPrinterList,printOneByName} from "@/utils/lodop"
import {batchTake, getSelfOrder, getStoreSendoutSetting, getTakeOrder} from "@/api/order";
export default {
  name: "orderList",
  components: {
    "download-excel": JsonExcel,
  },
  data() {
    return {
      batchTakeModal:false,
      batchTakeOrders:[],
      orderTakeModal:false,
      orderTakeForm:{},
      loading: true, // 表单加载状态
      modalVisible: false, // 添加或编辑显示
      modalTitle: "批量发货", // 添加或编辑标题
      orderDeliverLoading: false,
      pointer:"",
      tip:"批量发货中,请不要刷新页面,以防止打印面单失败",
      //批量发货
      deliver:{
        num:0,
        logisticsList: [],
        printerList:[],
        printer:"",
      },
      //自动打印小票设置
      receiveModalVisible:false,
      autoReceiveClass:"background-color:red",
      autoReceiveBtn:"自动打印小票设置",
      receive:{},
      // 表单验证规则
      formValidate: {
        addressName: [
          {
            required: true,
            message: "请输入地址名称",
            trigger: "blur",
          },
        ],
        longitude: [
          {
            required: true,
            message: "请输入地址经度",
            trigger: "blur",
          },
        ],
        latitude: [
          {
            required: true,
            message: "请输入地址纬度",
            trigger: "blur",
          },
        ],
        addressDetail: [
          {
            required: true,
            message: "请输入详细地址",
            trigger: "blur",
          },
        ],

        mobile: [
          {
            required: true,
            message: "请输入联系电话号",
            trigger: "blur",
          },
          { validator: validateMobile,
            trigger: "blur"
          }
        ],
        address: [
          {
            required: true,
            message: "请选择所在区域",
            trigger: "blur",
          },
        ],
      },
      searchForm: {
        // 搜索框初始化对象
        pageNumber: 1, // 当前页数
        pageSize: 10, // 页面大小
        sort: "", // 默认排序字段
        order: "", // 默认排序方式
        startDate: "", // 起始时间
        endDate: "", // 终止时间
        orderSn: "",
        buyerName: "",
        orderStatus: "",
        orderType: "NORMAL",
      },
      selectDate: null,
      columns: [
        {
          title: "订单号",
          key: "sn",
          minWidth: 200,
          tooltip: true,
        },
        {
          title: "订单来源",
          key: "clientType",
          width: 120,
          render: (h, params) => {
            if (params.row.clientType == "H5") {
              return h("div", {}, "移动端");
            } else if (params.row.clientType == "PC") {
              return h("div", {}, "PC端");
            } else if (params.row.clientType == "WECHAT_MP") {
              return h("div", {}, "小程序端");
            } else if (params.row.clientType == "APP") {
              return h("div", {}, "APP端");
            } else {
              return h("div", {}, params.row.clientType);
            }
          },
        },
        {
          title: "订单类型",
          key: "orderPromotionType",
          width: 120,
          render: (h, params) => {
            if (params.row.orderPromotionType == "NORMAL") {
              return h("div", [
                h("tag", { props: { color: "blue" } }, "普通订单"),
              ]);
            } else if (params.row.orderPromotionType == "PINTUAN") {
              return h("div", [
                h("tag", { props: { color: "volcano" } }, "拼团订单"),
              ]);
            } else if (params.row.orderPromotionType == "GIFT") {
              return h("div", [
                h("tag", { props: { color: "green" } }, "赠品订单"),
              ]);
            } else if (params.row.orderPromotionType == "POINTS") {
              return h("div", [
                h("tag", { props: { color: "geekblue" } }, "积分订单"),
              ]);
            } else if (params.row.orderPromotionType == "KANJIA") {
              return h("div", [
                h("tag", { props: { color: "pink" } }, "砍价订单"),
              ]);
            }
          },
        },
        {
          title: "商品",
          key: "groupName",
          minWidth: 130,
          tooltip: true,
        },
        {
          title: "买家名称",
          key: "memberName",
          minWidth: 130,
          tooltip: true,
        },
        {
          title: "支付方式",
          key: "paymentMethod",
          minWidth: 100,
          tooltip: true,
          render: (h, params) => {
            if (params.row.paymentMethod == "WECHAT") {
              return h("div", {}, "微信");
            } else if (params.row.paymentMethod == "ALIPAY") {
              return h("div", {}, "支付宝");
            }
          },
        },
        {
          title: "订单金额",
          key: "flowPrice",
          minWidth: 100,
          tooltip: true,
          render: (h, params) => {
            return h("priceColorScheme", {props:{value:params.row.flowPrice,color:this.$mainColor}} );
          },
        },

        {
          title: "订单状态",
          key: "orderStatus",
          minWidth: 100,
          render: (h, params) => {
            if (params.row.orderStatus == "UNPAID") {
              return h("div", [
                h("tag", { props: { color: "magenta" } }, "未付款"),
              ]);
            } else if (params.row.orderStatus == "PAID") {
              return h("div", [
                h("tag", { props: { color: "blue" } }, "已付款"),
              ]);
            } else if (params.row.orderStatus == "UNDELIVERED") {
              return h("div", [
                h("tag", { props: { color: "geekblue" } }, "待发货"),
              ]);
            }else if (params.row.orderStatus == "STAY_PICKED_UP") {
              return h("div", [
                h("tag", { props: { color: "geekblue" } }, "待自提"),
              ]);
            } else if (params.row.orderStatus == "DELIVERED") {
              return h("div", [
                h("tag", { props: { color: "cyan" } }, "已发货"),
              ]);
            } else if (params.row.orderStatus == "COMPLETED") {
              return h("div", [
                h("tag", { props: { color: "green" } }, "已完成"),
              ]);
            } else if (params.row.orderStatus == "TAKE") {
              return h("div", [
                h("tag", { props: { color: "volcano" } }, "待核验"),
              ]);
            } else if (params.row.orderStatus == "CANCELLED") {
              return h("div", [
                h("tag", { props: { color: "red" } }, "已取消"),
              ]);
            }
          },
        },
        {
          title: "核销码",
          key: "verificationCode",
          width: 100,
        },
        {
          title: "配送方式",
          key: "deliveryMethod",
          width: 100,
          render: (h, params) => {
            if (params.row.deliveryMethod == "LOGISTICS") {
              return h("div", {}, "物流");
            } else if (params.row.deliveryMethod == "SELF_PICK_UP") {
              return h("div", {}, "自提");
            }else if (params.row.deliveryMethod == "LOCAL_TOWN_DELIVERY") {
              return h("div", {}, "同城配送");
            }
          },
        },
        {
          title: "下单时间",
          key: "createTime",
          width: 170,
        },
        {
          title: "店名",
          key: "storeName",
          width: 100,
        },
        {
          title: "操作",
          key: "action",
          align: "center",
          minWidth: 280,
          render: (h, params) => {
            return h("div", [
              h(
                "Button",
                {
                  props: {
                    type: "info",
                    size: "small",
                    disabled:!(params.row.orderStatus==="UNDELIVERED"),
                  },
                  style: {
                    marginRight: "5px",
                  },
                  on: {
                    click: () => {
                      this.detail(params.row);
                    },
                  },
                },
                "发货"
              ),
              h(
                "Button",
                {
                  props: {
                    type: "info",
                    size: "small",
                    disabled:!(params.row.orderStatus==="STAY_PICKED_UP"),
                  },
                  style: {
                    marginRight: "5px",
                  },
                  on: {
                    click: () => {
                      this.orderTake(params.row);
                    },
                  },
                },
                "核销订单"
              ),
              h(
                "Button",
                {
                  props: {
                    type: "info",
                    size: "small",
                    disabled:!(params.row.orderStatus==="STAY_PICKED_UP"),
                  },
                  style: {
                    marginRight: "5px",
                  },
                  on: {
                    click: () => {
                      this.detail(params.row);
                    },
                  },
                },
                "打印小票"
              ),
              h(
                "Button",
                {
                  props: {
                    type: "info",
                    size: "small",
                  },
                  style: {
                    marginRight: "5px",
                  },
                  on: {
                    click: () => {
                      this.detail(params.row);
                    },
                  },
                },
                "查看"
              ),
            ]);
          },
        },
      ],
      data: [], // 表单数据
      total: 0, // 表单数据总数
      excelColumns: {
        // 导出excel的参数
        编号: "index",
        订单号: "sn",
        收货人: "consigneeName",
        收货人联系电话: "consigneeMobile",
        收货地址: "consigneeAddress",
        商品名称: "goodsName",
        商品价格: "goodsPrice",
        订单金额: "flowPrice",
        商品数量: "num",
        店铺名称: "storeName",
        创建时间: "createTime",
      },
    };
  },
  methods: {
    //获取批量订单核销数量
    getTakeOrder(){
      API_Order.getTakeOrder().then((res) => {
          if (res.success) {
            res.result.length;
            this.batchTakeModal = false;
          }
        }
      );
    },
    //批量核销
    batchTake(){
      API_Order.batchTake().then((res) => {
          if (res.success) {
            this.$Message.success("订单批量核销成功");
            this.batchTakeModal = false;
            this.getDataList();
          }
        }
      );
    },
    //弹出订单核销框
    orderTake (row) {
      this.orderTakeForm.verificationCode = row.verificationCode;
      this.orderTakeForm.sn=row.sn;
      this.orderTakeModal = true;
    },
    //订单核销提交
    orderTakeSubmit () {
      API_Order.orderTake(this.orderTakeForm.sn, this.orderTakeForm.verificationCode).then(
        (res) => {
          if (res.success) {
            this.$Message.success("订单核销成功");
            this.orderTakeModal = false;
            this.getDataList();
          }
        }
      );
    },
    showOrderDeliverModal2(){
      //查询接单设置
      API_Order.getStoreReceivingSetting("hand").then((res) => {
        if (res.success) {
          this.receive = res.result;
          //获取打印机
          this.receive.printerList = getPrinterList();
          this.receive.num=this.receive.orderList.length;
          this.receiveModalVisible=true;
        }
      });
    },
    //批量打印小票
    printBillsSubmit(){
      if (this.receive.num<=0){
        this.$Message.warning("待自提数量不能为0单");
        return;
      }
      if (this.receive.printer===""){
        this.$Message.warning("请选择自提打印机");
        return;
      }
      API_Order.getSelfOrder(this.receive).then((res) => {
        this.pointer="";
        if (res.success) {
          console.log(res.result);
          let printer = res.result.printer;
          res.result.orderList.forEach(function (item,index) {
            //打印小票
            //组合小票html页面

            printOneByName(printer,item.printTemplate)
          });
        }
      });
    },
    checkSelfOrder(){
      this.receiveModalVisible=false;
      this.searchForm.orderStatus="STAY_PICKED_UP";
      this.searchForm.pageNumber = 1;
      this.searchForm.pageSize = 10;
      this.getDataList();
    },
    checkOrder(){
      this.modalVisible=false;
      this.searchForm.orderStatus="UNDELIVERED";
      this.searchForm.pageNumber = 1;
      this.searchForm.pageSize = 10;
      this.getDataList();
    },
    logisticsItemFun(item){
      if (item.selected==="1"){
        item.selected="0"
      }else {
        item.selected="1"
      }
    },
    faceDelivery(){
      if (this.deliver.logistics ===""){
        this.$Message.warning("请选择物流");
        return;
      }
      if (this.deliver.printer===""){
        this.$Message.warning("请选择面单打印机");
        return;
      }
      API_Order.faceDelivery(this.deliver).then((res) => {
        this.pointer="";
        if (res.success) {
          console.log(res.result);
          let printer = res.result.printer;
          res.result.orderList.forEach(function (item,index) {
            //打印电子面单
            printOneByName(printer,item.printTemplate)
          });
        }
      });
    },
    //批量发货
    orderDeliverSubmit(){
      if (this.deliver.num<=0){
        this.$Message.warning("待发货数量不能为0单");
        return;
      }
      this.deliver.logistics="";
      for (let i = 0; i < this.deliver.logisticsList.length; i++) {
        if (this.deliver.logisticsList[i].selected==="1"){
          if (this.deliver.logistics === ""){
            this.deliver.logistics +=this.deliver.logisticsList[i].logisticsId;
          }else {
            this.deliver.logistics +=","+this.deliver.logisticsList[i].logisticsId;
          }
        }
      }
      if (this.deliver.logistics ===""){
        this.$Message.warning("请选择物流");
        return;
      }
      if (this.deliver.printer===""){
        this.$Message.warning("请选择面单打印机");
        return;
      }
      //console.log(this.deliver);
      this.pointer="pointer";
      API_Order.batchFaceDelivery(this.deliver).then((res) => {
        this.pointer="";
        if (res.success) {
          console.log(res.result);
          let printer = res.result.printer;
          res.result.orderList.forEach(function (item,index) {
            //打印电子面单
            printOneByName(printer,item.printTemplate)
          });
        }
      });
    },
    showOrderDeliverModal(){
      //查询曾经的设置
      API_Order.getStoreSendoutSetting("hand").then((res) => {
        if (res.success) {
          console.log(res);
          this.deliver = res.result;
          //获取打印机
          this.deliver.printerList = getPrinterList();
          this.modalVisible=true;
          this.deliver.num=this.deliver.orderList.length;
        }
      });

    },
    /**
     * 批量发货
     */
    expressOrderDeliver() {
      this.$router.push({
        path: "/export-order-deliver",
      });
    },
    // 初始化数据
    init() {
      this.getDataList();
    },
    // 改变页码
    changePage(v) {
      this.searchForm.pageNumber = v;
      this.getDataList();
    },
    // 改变页数
    changePageSize(v) {
      this.searchForm.pageSize = v;
      this.getDataList();
    },
    // 搜索订单
    handleSearch() {
      this.searchForm.pageNumber = 1;
      this.searchForm.pageSize = 10;
      this.getDataList();
    },
    // 重置
    handleReset() {
      this.searchForm = {};
      this.searchForm.pageNumber = 1;
      this.searchForm.pageSize = 10;
      this.selectDate = null;
      this.searchForm.startDate = "";
      this.searchForm.endDate = "";
      // 重新加载数据
      this.getDataList();
    },
    // 起始时间处理
    selectDateRange(v) {
      if (v) {
        this.searchForm.startDate = v[0];
        this.searchForm.endDate = v[1];
      }
    },
    // 获取表格数据
    getDataList() {
      this.loading = true;
      API_Order.getOrderList(this.searchForm).then((res) => {
        this.loading = false;
        if (res.success) {
          this.data = res.result.records;
          this.total = res.result.total;
        }
      });
    },
    // 导出的待发货订单数据
    async exportOrder() {
      let userInfo = JSON.parse(Cookies.get("userInfoSeller"));
      const params = {
        // 搜索框初始化对象
        pageNumber: 1, // 当前页数
        pageSize: 10000, // 页面大小
        sort: "startDate", // 默认排序字段
        order: "desc", // 默认排序方式
        startDate: "", // 起始时间
        endDate: "", // 终止时间
        orderSn: "",
        buyerName: "",
        tag: "WAIT_SHIP",
        orderType: "NORMAL",
        storeId: userInfo.id,
      };
      const res = await API_Order.queryExportOrder(params);
      if (res.success) {
        if (res.result.length === 0) {
          this.$Message.warning("暂无待发货订单");
          return [];
        }
        for (let i = 0; i < res.result.length; i++) {
          res.result[i].index = i + 1;
          res.result[i].consigneeAddress =
            res.result[i].consigneeAddressPath.replace(/,/g, "") +
            res.result[i].consigneeDetail;
          res.result[i].goodsPrice = this.$options.filters.unitPrice(
            res.result[i].goodsPrice,
            "￥"
          );
          res.result[i].flowPrice = this.$options.filters.unitPrice(
            res.result[i].flowPrice,
            "￥"
          );
        }
        return res.result;
      } else {
        this.$Message.warning("导出订单失败，请重试");
      }
    },
    // 查看订单详情
    detail(v) {
      let sn = v.sn;
      this.$options.filters.customRouterPush({
        name: "order-detail",
        query: { sn: sn },
      })

    },
  },
  mounted() {
    this.init();
  },
  // 页面缓存处理，从该页面离开时，修改KeepAlive为false，保证进入该页面是刷新
  beforeRouteLeave(to, from, next) {
    from.meta.keepAlive = false;
    next();
  },
};
</script>
<style lang="scss">
// 建议引入通用样式 可删除下面样式代码
@import "@/styles/table-common.scss";
.export {
  margin: 10px 20px 10px 0;
}
.pointer{
  pointer-events: none;
}

.bill{
  font-size: 10px;
}
hr{
  border: 0.5px dashed;
}
.place{
  font-size: 24px;
  font-weight: bold;
}
.self{
  padding-left: 100px;
}

</style>
